#!/usr/bin/env python
#-*- coding: GB2312 -*-


import importme
from models import model, page_parse

db_reader = model.reader
db_writer = model.writer


ROOT_FORM = 1 # virtual root id, fixed, do not modify


def main():
    print "Starting product init..."
    
    db_writer.product.delete()
    db_writer.form.where(id__neq=ROOT_FORM).delete()
    print "old data cleared"

    page_parse.init_forms(db_writer)
    print "forms inited"
    
    page_parse.init_products(db_writer)
    print "product inited"


if __name__ == '__main__':
    main()
